{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% block keywords %}{{ setting('site.seo_keywords') }}{% endblock %}
{% block description %}{{ setting('site.seo_description') }}{% endblock %}

{% set siteNav = "/" %}
{% set bodyClass = 'homepage' %}
{% set script_controller = 'index' %}

{% block full_content %}
  
  <!-- 轮播 -->
  {{ block_show('jianmo:home_top_banner') }}

  <!-- 课程列表 -->
  <section class="course-list-section" id="course-list">
    {% include 'TopxiaWebBundle:Default:course-grid-with-condition.html.twig' %}
  </section>
  {% set RecentLiveCourses = data('RecentLiveCourses',{ 'count':4}) %}
  {% if RecentLiveCourses %}
  <section class="live-course-section">
    <div class="container">
      <div class="text-line gray">
        <h5><span>近期直播</span><div class="line"></div></h5>
        <!-- <div class="subtitle">实时跟踪直播课程，避免课程遗漏。</div> -->
      </div>
      <div class="course-list">
        <div class="row">
          {% for course in RecentLiveCourses %}
            <div class="col-lg-3 col-md-4 col-sm-6">
              {% include 'TopxiaWebBundle:Course:Widget/course-grid.html.twig' with {course:course} %}

              {% set lesson = course['lesson']|default(null) %}
              {% if lesson and "now"|date("U") >= lesson.startTime and "now"|date("U") <= lesson.endTime %}
                <div class="course-date visible-lg">
                  <div class="btn-circle btn-live  btn-circle-md">
                    <i class="es-icon es-icon-videocam"></i>
                  </div>
                  <div class="date">
                    正在直播
                  </div>
                </div>
              {% else %}
                <div class="course-date visible-lg">
                  <div class="btn-circle btn-circle-md">
                    <i class="es-icon es-icon-videocam"></i>
                  </div>
                  <div class="date">
                    {{ lesson.startTime|date('n月j日 H:i') }}
                  </div>
                </div>
              {% endif %}

            </div>
          {% endfor %}

          {% set emptyCourseNum = 4 - RecentLiveCourses|length %}
          {% if emptyCourseNum > 0 %}
            {% for i in range(1, emptyCourseNum) %}
              <div class="col-lg-3 col-md-4 col-sm-6 visible-lg">
                <div class="course-item course-default">
                  <i class="es-icon es-icon-videocam"></i>
                  <br>
                  敬请期待
                </div>
                <div class="course-date">
                  <div class="btn-circle btn-circle-md">
                    <i class="es-icon es-icon-accesstime"></i>
                  </div>
                </div> 
              </div>
            {% endfor %}
          {% endif %}
        </div>
      </div>
      <div class="text-center mvl">
        <a href="{{ path('live_course_explore') }}" class="btn btn-default btn-lg">
          更多直播 <i class="mrs-o es-icon es-icon-chevronright"></i>
        </a>
      </div>
    </div>
  </section>
  {% endif %}

  <!-- 特性 -->
  {{ block_show('jianmo:middle_banner') }}


  <!-- 推荐班级 -->
  {% set RecommendClassrooms = data('RecommendClassrooms',{'count':4})%}
  {% if RecommendClassrooms %}
    <section class="class-section">
      <div class="container">
        <div class="text-line">
          <h5>
            <span>推荐{{ setting('classroom.name')|default("班级") }}</span>
            <div class="line"></div>
          </h5>
          <!-- <div class="subtitle">班级化学习体系，给你更多的课程相关服务。</div> -->
        </div>
        <div class="recommend-class-list row">
          {% for classroom in RecommendClassrooms %}
            <div class="col-md-3 col-sm-6">
               {% include 'ClassroomBundle:Classroom:class-grid.html.twig' %} 
            </div>
          {% endfor %}
        </div>
        <div class="text-center mvl">
          <a href="{{ path('classroom_explore') }}" class="btn btn-default btn-lg">
            更多{{ setting('classroom.name')|default("班级") }} <i class="mrs-o es-icon es-icon-chevronright"></i>
          </a>
        </div>
      </div>
    </section>
  {% endif %}

  <!-- 小组动态 -->
  {% set groups = data('HotGroup',{'count':6}) %}
  {% if groups %}
    <section class="group-dynamic">
      <div class="container">
        <div class="text-line gray">
          <h5><span>小组动态</span><div class="line"></div></h5>
          <!-- <div class="subtitle">参与小组，结交更多同学，关注课程动态。</div> -->
        </div>
        <div class="group-dynamic-body row">
          <div class="col-md-6">
            <div class="panel panel-default index-group">
              <div class="panel-heading">
                <a href="{{ path('group') }}" class="more"><i class="es-icon es-icon-morehoriz"></i></a>
                <h3 class="panel-title"><i class="es-icon es-icon-whatshot pull-left"></i>热门小组</h3>
              </div>
              <div class="panel-body row">
                {% for group in groups %}
                  <div class="media media-group col-md-6 col-sm-4">
                    <div class="media-left">
                      <a href="{{ path('group_show',{id:group.id}) }}">
                        {% if group.logo %}
                          <img class="avatar-square-md" src="{{file_path(group.logo)}}">
                        {% else %}
                          <img class="avatar-square-md" src="{{asset('assets/img/default/group.png')}}">
                        {% endif %}
                      </a>
                    </div>
                    <div class="media-body">
                      <div class="title">
                        <a class="link-light" href="{{ path('group_show',{id:group.id}) }}">
                          {{ group.title }}
                        </a>
                      </div>
                      <div class="metas">
                        <span><i class="es-icon es-icon-people"></i>{{ group.memberNum }}</span>
                        <span><i class="es-icon es-icon-textsms"></i>{{ group.threadNum }}</span>
                      </div>
                    </div>
                  </div>
                {% endfor %}
              </div>
            </div>
          </div>
          <div class="col-md-6">
            <div class="panel panel-default index-dynamic">
              <div class="panel-heading">
                <h3 class="panel-title">
                  <i class="es-icon es-icon-recentactors pull-left"></i>学员动态
                </h3>
              </div>
              <div class="panel-body">
                {% set statuses = data('LatestStatuses', {mode:'simple', count: 4,private:0}) %}

                {% for status in statuses %}
                  <div class="media media-dynamic">
                    <div class="media-left">
                      {{ web_macro.user_avatar(status.user, '', 'avatar-sm') }}
                    </div>
                    <div class="media-body">
                      <div class="title">
                        {{ web_macro.user_link(status.user) }}
                      </div>
                      <div class="content">
                        {{ status.message|raw }}
                      </div>
                      <span class="date">{{status.createdTime | smart_time}}</span>
                    </div>
                  </div>
                {% endfor %}
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  {% endif %}

  <!-- 推荐教师 -->
  {% set teachers = data('RecommendTeachers',{'count':4}) %}
  {% if teachers %}
  <section class="recommend-teacher">
    <div class="container">
      <div class="text-line">
        <h5><span>推荐教师</span><div class="line"></div></h5>
        <!-- <div class="subtitle">名师汇集，保证教学质量与学习效果。</div> -->
      </div>
      <div class="row">
        {% for teacher in teachers %}
        {% set profile = teacher.profile %}
        {% set isFollowed = teacher.isFollowed %}
          <div class="col-md-3 col-sm-6">
            {% include 'TopxiaWebBundle:Teacher:teacher-item.html.twig' %}
          </div>
        {% endfor %}
      </div>
      <div class="text-center mvl">
        <a href="{{ path('teacher') }}" class="btn btn-default btn-lg">
          更多教师 <i class="mrs-o es-icon es-icon-chevronright"></i>
        </a>
      </div>
    </div>
  </section>
  {% endif %}

{% endblock %}